package org.qiyu.live.api.websockerDemo;

import java.io.IOException;
import java.io.InputStream;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @ClassName: 接收端
 * @Description: TODO
 * @Author zhangguangyan
 * @Date 2023/09/02/ 10:41:13
 * @Version 1.0
 */
public class BioService {
    public static void main(String[] args) throws IOException {
        ServerSocket serverSocket = new ServerSocket();
        //绑定端口
        serverSocket.bind(new InetSocketAddress(9090));
        //阻塞,接收外界的链接
        Socket socket = serverSocket.accept();
        while (true){
            //获取数据的输入流
            InputStream inputStream = socket.getInputStream();
            byte [] bytes =new byte[10];
            //阻塞调用
            inputStream.read(bytes);
            System.out.println("服务器接收到的数据:"+new String(bytes));
        }
    }
}
